package com.lin.mr.maizilaundry.activity;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

import com.lin.mr.maizilaundry.R;
import com.lin.mr.maizilaundry.view.SwitchView;

public class CustomSwitchActivity extends Activity {
    private SwitchView switchView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_custom_switch);
        switchView = (SwitchView) findViewById(R.id.switchView);

        //设置开关更新监听
        switchView.setOnSwitchStateUpdateListener(new SwitchView.OnSwitchStateUpdateListener() {
            @Override
            public void onStateUpdate(boolean state) {
                if (state){
                    Toast.makeText(getApplicationContext(), "开关已打开(∩_∩)", Toast.LENGTH_SHORT).show();
                }else {
                    Toast.makeText(getApplicationContext(), "开关已关闭(@_@;)", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
